export default {
  state: { // state
    baseInfo: '',
    token: '',
    nowDate: ''
  },
  getters: {
    baseInfo: state => state.baseInfo,
    token: state => state.token,
    nowDate: state => state.nowDate
  },
  mutations: {
    SAVE_INFO (state, data) {
      state.baseInfo = data
    },
    SAVE_TOKEN (state, data) {
      state.token = data
    },
    UPDATE_CHANCE (state, data) {
      state.baseInfo.answerTimes = state.baseInfo.answerTimes - 1
    },
    UPDATE_NOWDATE (state, data) {
      let nowdate = new Date(data).getDate()
      console.log(nowdate, 1111)
      state.nowDate = nowdate
    }
  },
  actions: {
    saveInfo ({dispatch, commit}, data) {
      commit('SAVE_INFO', data)
    },
    getToken ({dispatch, commit}, data) {
      commit('SAVE_TOKEN', data)
    },
    updateChance ({dispatch, commit}) {
      commit('UPDATE_CHANCE')
    },
    getNowDate ({dispatch, commit}, data) {
      commit('UPDATE_CHANCE', data)
    }
  }
}
